//
// Created by 29019 on 2019/9/11.
//

#ifndef LIBRTSP_C_LIBRTSP_H
#define LIBRTSP_C_LIBRTSP_H

#include "sock.h"
#include "stdio.h"
#include <string.h>
#ifdef __cplusplus
extern  "C" {
#endif

#ifdef linux
typedef int bool;
#define TRUE 1
#define FALSE 0
#endif
typedef struct _T_Param {
    char key[50];
    char value[140];
} Params;

typedef struct _T_RtspClientCtx {
    char hostIp[30];
    int port;
    char despcrtion[50];
    Sock sock;
    int cesq;
    bool conn;
    char session[50];
} RtspClient;

// callback function that receive data.
typedef int (CallBack)(RtspClient *client, const char *data, int len);

typedef enum _E_Method {
    E_OPTIONS = 0,
    E_POST,
    E_ANNOUNCE,
    E_SETUP,
    E_RECORD
} Methods;

extern RtspClient *gRtspclient;

RtspClient *ConectRtsp(char *ip, int port, char *desc);

int GenPayload(Methods method, char *data);

int SendOption(RtspClient *p, CallBack *c);

int SendSetup(RtspClient *p, CallBack *c);

int SendRecord(RtspClient *p, CallBack *c);

int SendAnnounce(RtspClient *p, CallBack);

int SendRtpPackage(RtspClient *p, unsigned char *buf, int length);


int CallBackSetup(RtspClient *client, const char *data, int len);
#ifdef __cplusplus
}
#endif
#endif //LIBRTSP_C_LIBRTSP_H
